<CFSET session.tabId = "collab">
<CFSET session.sModules="main;books;collab;files;forms;browsers;graphs;reports;queries;rooms;tasks;reminders;utilities;forms">
<CFSET session.smodulenames="eBoard;eBooks;eForums;eFiles;eForms;eViews;eGraphs;eReports;eQueries;eRooms;eTasks;eReminders;eAdmin;eForms">
<!--- Get threads for selected folder --->
<CFIF qryECRGCOLLAB.FOLDERTYPE IS "shared">
	<CFQUERY NAME="QueryView" DATASOURCE="#client.company_dsn#">
		SELECT A.COLLABCODE, SUBJECT, DATECREATED, TIMECREATED, READMSG
		FROM ECRGCOLLABTHREAD A, ECINCOLLABUSER B
		WHERE A.FOLDERCODE = '#url.id#' AND
			  A.COLLABCODE = B.COLLABCODE AND
			  B.USERID = '#client.userid#'
		<CFIF IsDefined("form.edtValFilter") AND form.edtValFilter IS NOT "">
			AND #form.cmbSort# LIKE '#form.edtValFilter#%'
		</CFIF>
		<CFIF IsDefined("form.cmbSort")>
			ORDER BY #form.cmbSort# <CFIF IsDefined("form.ascdesc")>#form.ascdesc#</CFIF>
		</CFIF>
	</CFQUERY>
<CFELSE>
	<CFQUERY NAME="QueryView" DATASOURCE="#client.company_dsn#">
		SELECT A.COLLABCODE AS COLLABCODE, SUBJECT, DATECREATED, TIMECREATED, READMSG
		FROM ECRGCOLLABTHREAD A, ECINCOLLABUSER B, ECRGCOLLABMOVE C
		WHERE C.FOLDERCODE = '#url.id#' AND
			  C.COLLABCODE = A.COLLABCODE AND
			  C.COLLABCODE = B.COLLABCODE AND
			  B.USERID = '#client.userid#'
		<CFIF IsDefined("form.edtValFilter") AND form.edtValFilter IS NOT "">
			AND #form.cmbSort# LIKE '#form.edtValFilter#%'
		</CFIF>
		<CFIF IsDefined("form.cmbSort")>
			ORDER BY #form.cmbSort# <CFIF IsDefined("form.ascdesc")>#form.ascdesc#</CFIF>
		</CFIF>
	</CFQUERY>
</CFIF>

<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="#qryECRGCOLLAB.DESCRIPTION#">

<CFIF sUpdateMsg IS NOT "">
	<CFOUTPUT>
		<b>#sUpdateMsg#</b>
	</CFOUTPUT>
</CFIF>

<CFOUTPUT>
<form method="post" action="#getfileFromPath(getBaseTemplatePath())#?id=#URLEncodedFormat(Encrypt(url.id, client.ek))#" name="index">
</CFOUTPUT>
<CFSET frmName="index">

<!--- get user role for current folder --->
<CFIF qryECRGCOLLAB.FOLDERTYPE IS "shared">
	<CFMODULE TEMPLATE="..\common\getaccess.cfm" ID="#url.id#">
	<CFIF ISADMIN IS "Y">
		<!--- parameters for lstAddtnlButton (button name, button value, button hint) --->
		<CFSET lstAddtnlButton="btnCreateThread~Create Discussion~Create Discussion">
	</CFIF>
<CFELSE>
	<CFSET lstAddtnlButton="btnMoveDiscussion~Move Discussion~Move Discussion">
</CFIF>

<CFSET lstOrder="Subject~SUBJECT~ftstring," & 
				"Date Created~DATECREATED~ftstring," & 
				"Time Created~TIMECREATED~ftstring">
<CFINCLUDE TEMPLATE="#client.common_path#toolbar.cfm">

<table border=0 cellspacing=1 cellpadding=0 WIDTH="100%">
<CFIF NOT QueryView.RecordCount>
	<tr><td class="bold"><br>No records found in the current filter.</td></tr>
<CFELSE>
	<CFOUTPUT>
	<tr bgcolor="#client.color_grphead#">
	</CFOUTPUT>
		<td>&nbsp;</td>
		<td height="18" class="boldwhite">&nbsp;Subject</td>
		<td class="boldwhite">&nbsp;Date Created</td>
		<td class="boldwhite">&nbsp;Time Created</td>
		<td class="boldwhite">&nbsp;Replies</td>
		
	</tr>					
	
	<CFOUTPUT QUERY="QueryView" STARTROW="#nStartrow#" MAXROWS="#Evaluate(nEndrow - nStartrow + 1)#">
		<CFQUERY NAME="qryECINCOLLABDISC" DATASOURCE=#client.company_dsn#>
			SELECT SORTID
			FROM ECINCOLLABDISC
			WHERE COLLABCODE = '#QueryView.COLLABCODE#'
		</CFQUERY>						
						
		<!--- Count unread messages --->				
		<CFSET nUnReadMessages=0>
		
		<!--- put QueryView.READMSG to lstReadMsg variable to avoid logical error. Bug on CF --->
		<CFSET lstReadMsg=QueryView.READMSG>
		
		<CFLOOP QUERY="qryECINCOLLABDISC">
			<CFIF ListFind(lstReadMsg, Trim(qryECINCOLLABDISC.SORTID)) IS 0>
				<CFSET nUnReadMessages=nUnReadMessages + 1>
			</CFIF>
		</CFLOOP>		
	
		<tr bgcolor="#IIf(CurrentRow Mod 2, "client.color_tblset2", "client.color_tblset1")#" valign="top">
			<td align="center">
				<cfif QueryView.READMSG eq "N">
					<img src="#client.icon_path#new_read_forums.gif" title="New reply" />
				</cfif>
			</td>
			<td height=17>&nbsp;<a class="regular11" href="#getfileFromPath(getBaseTemplatePath())#?id=#URLEncodedFormat(encrypt(url.id, client.ek))#&collab=#URLEncodedFormat(encrypt(QueryView.COLLABCODE, client.ek))#">#SUBJECT#</a></td>
			<td class="regular11">&nbsp;#DateFormat(DATECREATED, "mmm dd, yyyy")#</td>
			<td class="regular11">&nbsp;#TIMECREATED#</td>
			<td class="regular11">#qryECINCOLLABDISC.RecordCount-1#</td>
		</tr>
	</CFOUTPUT>
	<CFOUTPUT>
		<tr><td height=18 class="boldwhite" bgcolor="#client.color_grphead#" width="100%" colspan="5">
			&nbsp;&nbsp;Records:&nbsp;#nStartrow#-#nEndrow#&nbsp;&nbsp;of&nbsp;&nbsp;#QueryView.RecordCount#
		</td></tr>
	</CFOUTPUT>
</CFIF>
</table>

</form>

<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">